<?php
namespace app\index\controller;

use lib\Db;
use lib\Session;
use lib\Response;

class Book extends Common{

    function index(){
        return $this->fetch();
    }


    /**
     * 日记本列表
     * @return array
     * @throws \Exception
     */
    function _list(){
        $uid = $this->request->data['uid'];
        if(!is_numeric($uid)){
            if(Session::get('uid')){
                $uid = Session::get('uid');
            }else{
                $this->error('获取uid失败!');
            }
        }
        $page = $this->data('page') ? $this->data('page') : 1;
        $length = $this->data('length') ? $this->data('length') : 1;
        $list = Db::name('book')->where(['uid'=>$uid])->page($page, $length)->select();
        return Response::success('ok', $list);
    }

}